<html>
<head>
<style type="text/css">
#more_button{
float:left;
}
.more{
	float:left;
	border:1px solid #b1b1b1;
	width:535px;
	height:37px;
	margin: 20 20 10 20;
	text-align:center;
	padding:5;
	-moz-border-radius: 5px; -webkit-border-radius: 5px;
	font-size:14px;
	font-weight:bold;
	text-shadow:1px 1px 1px #FFFFFF;
	background:white;
	cursor:pointer;
}
.more:hover {
	border:1px solid #BBBBBB;
	text-decoration:none;
	background:#f6f6f6;
}
.more:active {
	color:#666666;
}

ul li { display: inline; }
</style>
<script type="text/javascript" src="<?php echo base_url()?>js/jquery.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>js/jquery-ui.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>js/jquery.timeago.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>css/jquery-ui.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>css/styles.css"/>
<link rel="stylesheet" href="http://localhost/ta/css/prettyPhoto.css" type="text/css" media="screen" title="prettyPhoto main stylesheet" charset="utf-8" />
<script src="http://localhost/ta/js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script>
		
<script type="text/javascript">
$(document).ready(function() {



			$(".gallery:first a[rel^='prettyPhoto']").prettyPhoto({theme:'light_rounded'});
			$(".gallery3 a[rel^='prettyPhoto']").prettyPhoto({theme:'light_rounded'});
			//$(".gallery:gt(0) a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'fast',slideshow:10000});
			
			/*$("#custom_content a[rel^='prettyPhoto']:first").prettyPhoto({
				custom_markup: '<div id="map_canvas" style="width:260px; height:265px"></div>',
				changepicturecallback: function(){ initialize(); }
			});*/

			$("#custom_content a[rel^='prettyPhoto']:last").prettyPhoto({
				custom_markup: '<div id="bsap_1237859" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6" style="height:260px"></div><div id="bsap_1251710" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6"></div>',
				changepicturecallback: function(){ _bsap.exec(); }
			});

		
	$('#ajaxLoadAnipne' ).hide();
	jQuery(".time").timeago();
		
	var num_messages = <?php echo $num_messages?>;
		var loaded_messages = 0;
		var loaded = 10;
		var addpanel = 0;
		var id =  <?php echo $data2->id_place?>;
		
		if (loaded >= num_messages){
			$("#more_button").hide();
		}
		
		$('.loading').hide();
		$("#more_button").click(function(){
			loaded_messages += 10;
			addpanel += 1;
			$.ajax({
				type: "post",
				url: "http://localhost/ta/place/get_comments/" + id + "/" + loaded_messages,
				data: $.param({add:addpanel}),
				beforeSend:  function() {
					$('.text').hide();
					$("#more").append($('.loading').show());
				},
				success: function(data){
					//alert(addpanel);
					$('.loading').hide();
					$('.text').show();
					$("#main_content").append(data);
					if(loaded_messages >= num_messages - 10){
						$("#more_button").remove();
					}else{
						$("#main_content").append($("#more_button"));
					}
				}
			});
		});	
		
	$(".post_button").click(function() 
	{
		var element = $(this);
	    var input_content = $(".clposting").val();
	    var input_idpost = $(".clposting2").val();
		if(input_content == '' || input_idpost == '' )
		{
			alert("Please Enter Some Text"+input_content+input_idpost);
			$( '#ajaxLoadAnipne' ).hide();
		}
		else
		{
			$( '#ajaxLoadAnipne' ).fadeIn(3000);
			$.ajax({
					
					type: "POST",
			  		url: 'http://localhost/ta/place/add',
			   		data: $.param({content:input_content,idpost:input_idpost}),
			   		dataType:'json',
			  		cache: false,
			  		success: function(out){
						$('#ajaxLoadAnipne').fadeOut(3000);
			  			$("ol#update").prepend('<div id="newcomment">'+
													/*'<li style="display:none">'+
													'<div id="newpost">'+
													'<div class="photo">'+out.photo+'</div>'+
													'<div class="username"><b>'+out.username+'</b></div>'+
													'<div class="kotakstatus3"><div class="status2">'+out.content+'</div>'+
													'<div class="time">'+out.time+'</div></div>'+
													'<div class="clear"></div>'+
													'</div>'+
												'</li>'*/
												'</div>');
			  			$("ol#update li:first").fadeIn(3000);
						$('#newcomment').load('<?php echo base_url();?>place/get_new').fadeIn('slow');					
					}
			 });
		}
		return false;
	});
	
	
	
	
	
	$('.likebuttonx').hide();
	$('.unlikebuttonx').hide();
	
	$('.likebutton').live("click",function() 
	{
		var item = $(this);
		var I = item.attr("likeid");
		$('#likebutton'+I).hide();
		$('#unlikebuttonx'+I).show();
		{
			$.ajax({
				type: "POST",
			 	url: "http://localhost/ta/place/like",
			  	data: $.param({id_post:item.attr("likeid")}),
			 	cache: false,
			 	success: function(html){
					var item = $(this);
					var $konfirmasi = $("<div></div>" )
						.html('Your vote was added.')
						.dialog({
							title: 'Like Place',
							autoOpen: false,
							resizable: false,
							height:140,
							modal: true,
							buttons: {
								"Ok": function() {
									$( this ).dialog( "close" );
								}
							}
						});	
					$konfirmasi.dialog('open');
					return false;
			 	}
			});
		}
		return false;
	});
	
	$('.likebuttonx').live("click",function() 
	{
		var item = $(this);
		var I = item.attr("likeid");
		$('#likebuttonx'+I).hide();
		$('#unlikebutton'+I).show();
		{
			$.ajax({
				type: "POST",
			 	url: "http://localhost/ta/place/like",
			  	data: $.param({id_post:item.attr("likeid")}),
			 	cache: false,
			 	success: function(html){
					var item = $(this);
					var $konfirmasi = $("<div></div>" )
						.html('Your vote was added.')
						.dialog({
							title: 'Like Place',
							autoOpen: false,
							resizable: false,
							height:140,
							modal: true,
							buttons: {
								"Ok": function() {
									$( this ).dialog( "close" );
								}
							}
						});	
					$konfirmasi.dialog('open');
					return false;
			 	}
			});
		}
		return false;
	});
	
	$('.unlikebutton').live("click",function() 
	{
		var item = $(this);
		var I = item.attr("likeid");
		$('#unlikebutton'+I).hide();
		$('#likebuttonx'+I).show();
		{
			$.ajax({
				type: "POST",
			 	url: "http://localhost/ta/place/unlike",
			  	data: $.param({id_post:item.attr("likeid")}),
			 	cache: false,
			 	success: function(html){
			 		var item = $(this);
					var $konfirmasi = $("<div></div>" )
						.html('Your vote was removed.')
						.dialog({
							title: 'Unlike Place',
							autoOpen: false,
							resizable: false,
							height:140,
							modal: true,
							buttons: {
								"Ok": function() {
									$( this ).dialog( "close" );
								}
							}
						});	
					$konfirmasi.dialog('open');
					return false;
			 	}
			});
		}
		return false;
	});
	
	$('.unlikebuttonx').live("click",function() 
	{
		var item = $(this);
		var I = item.attr("likeid");
		$('#unlikebuttonx'+I).hide();
		$('#likebutton'+I).show();
		{
			$.ajax({
				type: "POST",
			 	url: "http://localhost/ta/place/unlike",
			  	data: $.param({id_post:item.attr("likeid")}),
			 	cache: false,
			 	success: function(html){
			 		var item = $(this);
					var $konfirmasi = $("<div></div>" )
						.html('Your vote was removed.')
						.dialog({
							title: 'Unlike Place',
							autoOpen: false,
							resizable: false,
							height:140,
							modal: true,
							buttons: {
								"Ok": function() {
									$( this ).dialog( "close" );
								}
							}
						});	
					$konfirmasi.dialog('open');
					return false;
			 	}
			});
		}
		return false;
	});
	

	
	$('a.delete').click(function() 
	{
		var item = $(this);
		var content = item.attr("del_id");		
		var $konfirmasi = $("<div></div>" )
			.html('Are you sure want to delete this place?')
			.dialog({
				title: 'Delete Place',
				autoOpen: false,
				resizable: false,
				height:140,
				modal: true,
				buttons: {
					"Yes": function() {
						$.ajax({
							type: "POST",
							url: "http://localhost/ta/place/delete_place",
							data: $.param({idpost:content}),
							cache: false,
							success: function(html){
								setTimeout("this.location = 'http://localhost/ta/place' ",1000);
							}
						});
						$( this ).dialog( "close" );
					},
					"No": function() {
						$( this ).dialog( "close" );
					}
				}
			});	
		$konfirmasi.dialog('open');
		return false;
	});
	
	
	$('.delete_update').click(function() 
	{
		var item = $(this);
		var $konfirmasi = $("<div></div>" )
			.html('Are you sure want to delete this comment?')
			.dialog({
				title: 'Delete Comment Place',
				autoOpen: false,
				resizable: false,
				height:140,
				modal: true,
				buttons: {
					"Yes": function() {
						$.ajax({
							type: "POST",
							url: "http://localhost/ta/place/del_com",
							data: $.param({id_comment:item.attr("del_id")}),
							cache: false,
							success: function(html){
								//alert('aa'+item.attr("del_id")+item.attr("cat"));
								$("#row_"+item.attr("del_id")).slideUp('slow', function() {$(this).remove();});
							}
						});
						$( this ).dialog( "close" );
					},
					"No": function() {
						$( this ).dialog( "close" );
					}
				}
			});	
		$konfirmasi.dialog('open');
		return false;
	});
	
	$('.delfotoplace').click(function() 
	{
		var item = $(this);		
		var $konfirmasi = $("<div></div>" )
			.html('Are you sure want to delete this photo?')
			.dialog({
				title: 'Delete Photo',
				autoOpen: false,
				resizable: false,
				height:140,
				modal: true,
				buttons: {
					"Yes": function() {
						$.ajax({
							type: "POST",
							url: "http://localhost/ta/place/del_photo",
							data: $.param({id_photo:item.attr("idphoto"),id_place:item.attr("idplace")}),
							cache: false,
							success: function(html){	
								setTimeout("this.location = 'http://localhost/ta/place/view/"+item.attr("idplace")+"' ",1000);
							}
						});
						$( this ).dialog( "close" );
					},
					"No": function() {
						$( this ).dialog( "close" );
					}
				}
			});	
		$konfirmasi.dialog('open');
		return false;
	});
	
	$('.myphoto2').hide();
	$('.myphoto3').hide();
	$('.myphoto4').hide();
	$('.editphoto').click(function(){
		$('.myphoto').hide();
		$('.myphoto3').hide();
		$('.myphoto2').show();
	}); 
	
	$('.canceladd').click(function(){
		$('.myphoto4').hide();
		$('.myphoto2').hide();
		$('.myphoto').show();
	}); 
	
	$('.cancelchange').click(function(){
		$('.myphoto4').hide();
		$('.myphoto3').hide();
		$('.myphoto2').hide();
		$('.myphoto').show();
	}); 

	$('.changephoto').click(function(){
		$('.myphoto2').hide();
		$('.myphoto3').show();
		$('.myphoto').hide();
	}); 
	
	$('.addphoto').click(function(){
		$('.myphoto2').hide();
		$('.myphoto4').show();
		$('.myphoto').hide();
	}); 
	
});
</script>
</head>

<body>
<div id="wrapper">
<div id="wrapper2">
	<div id="leftcolumn">
		<?php echo $this->load->view('place/map_place');?>	
		
		<?php foreach($data as $row):?>
		<div id="statuspne">
				<form action="" method="post">
				<textarea class="clposting" id="styleidpne" name="content1"></textarea>
				<input type="hidden" class="clposting2" name="content2" value="<?php echo $row->idp?>">
					<div id="loadingpne">
						<span class="countdown"></span>
						<div id="ajaxLoadAnipne">
							<img src="<?php echo base_url()?>img/loading6.gif" alt="Ajax Loading Animation" />
						</div>
						<input type="submit" id="submit" class="post_button" name="submit" value="Review"/>
					</div>
				</form>
		</div>
		<?php endforeach ?>
		
			
			<?php echo $this->load->view('place/place_list');?>
			<div id="more_button">
				<button id="more" class="more" ><span class="text">More</span></button>
				<div class="loading"><img src="http://localhost/ta/img/twitloading.gif" /></div>
			</div>
	
	</div>
	
	
	<div id="rightcolumn">
		<div id="infoplace">
			<?php foreach($data as $row):?>				
				<?php foreach($vote as $row2){
					if ($row2->total > 1){
						echo '<div class="starplace">'.img(array('src'=>'http://localhost/ta/img/star.png')).'</div>';
					}else if ($row2->total == 1) {
						echo '<div class="starplace">'.img(array('src'=>'http://localhost/ta/img/halfstar.png')).'</div>';
					}else if ($row2->total == 0) {
						echo '<div class="starplace">'.img(array('src'=>'http://localhost/ta/img/whitestar.png')).'</div>';
					}
					
				}?>
				<?php echo '<span style="color:#1dd012;font-size:20;font-weight:bold;">'.$row->name.'</span>'?>
				<div class="clear"></div>
				<br>
				<?php echo '<span style="color:#1dd012;">Description</span><div class="fulldesc">'.$row->description.'</div>'?>
				<?php echo '<span style="color:#1dd012;">Address</span><div class="fulladdress">'.$row->street.'</div>'?>
				<?php echo '<div class="author"><div class="created">Created by </div>';
						if ($row->iduser == $this->session->userdata('id_user')){
							if ($row->avatar == 0){
								echo '<div class="by" title="'.$author->username.'">'.anchor('profile',img(array('src'=>'http://localhost/ta/img/default.jpg','width'=>20,'height'=>20))).'</div>';
							}else{
								echo '<div class="by" title="'.$author->username.'">'.anchor('profile',img(array('src'=>'img/thumb_foto/'.$author->filename,'width'=>20,'height'=>20))).'</div>';
							}
						}else{
							if ($row->avatar == 0){
								echo '<div class="by" title="'.$author->username.'">'.anchor('people/view/'.$author->id_user,img(array('src'=>'http://localhost/ta/img/default.jpg','width'=>20,'height'=>20))).'</div>';
							}else{							
								echo '<div class="by" title="'.$author->username.'">'.anchor('people/view/'.$author->id_user,img(array('src'=>'img/thumb_foto/'.$author->filename,'width'=>20,'height'=>20))).'</div>';
							}
						}
					  echo '</div>';
				?>
			<?php endforeach ?>
		</div>
		
		<div id="infovote">
		<div class="titlebox">Statistic</div>
		<div class="clear"></div>
		
			<?php foreach($vote as $row){
				echo '<div class="boxvotepost"><div class="labelvotepost">'.$row->total.'</div>Likes</div>';
			}?>
			<?php foreach($com as $row){
				echo '<div class="boxvotecom"><div class="labelvotecom">'.$row->total_com.'</div>Comments</div>';
			}?>
		
			<?php foreach($data as $row):?>
				<?php 
				echo '<div class="garis">';
				echo '<div class="action_like">';
				if ($row->idp == $row->idpv && $row->voter == $this->session->userdata('id_user')){
					echo '<div class="unlikebutton" id="unlikebutton'.$row->idp.'" likeid="'.$row->idp.'">'.anchor("#",'Unlike').'</div>';
					echo '<div class="likebuttonx" id="likebuttonx'.$row->idp.'" likeid="'.$row->idp.'">'.anchor("#",'Like').'</div>';
				}else{
					echo '<div class="likebutton" id="likebutton'.$row->idp.'" likeid="'.$row->idp.'">'.anchor("#",'Like').'</div>';		
					echo '<div class="unlikebuttonx" id="unlikebuttonx'.$row->idp.'" likeid="'.$row->idp.'">'.anchor("#",'Unlike').'</div>';		
				}
				echo '</div>';
				if ($row->iduser == $this->session->userdata('id_user')){
					echo '<div class="action_like">'.anchor('place/edit_map_place/'.$row->idp,'Edit').'</div>';
					echo '<div class="action_like">';
					echo '<a href="#" class="delete" del_id="'.$row->idp.'">Delete</a>';
					echo '</div>';
				}else if ($this->session->userdata('id_user') == 1 ){
					echo '<div class="action_like2">'.anchor('place/edit_map_place/'.$row->idp,'Edit').'</div>';
					echo '<div class="action_like2">';
					echo '<a href="#" class="delete" del_id="'.$row->idp.'">Delete</a>';
					echo '</div>';
				}else{
					echo'';
				}
				echo '</div>';
				?>
			<?php endforeach ?>
			
			
		</div>
		<div class="clear"></div>
		

		
		<div id="infophoto">
		<div class="titlebox">Photo</div>
		<?php if ($row->iduser == $this->session->userdata('id_user') || $this->session->userdata('id_user') == 1 ):?>
		<a href="javascript::void(0)" class="editphoto">edit photo</a>
		<?php endif?>
		<div class="clear"></div>
			<div class="myphoto">			
			<ul class="gallery">
			<?php foreach($data as $row):?>
				<div class="fotoplace">
				<li><a title="<?php echo $row->name?>" rel="prettyPhoto" href="http://localhost/ta/img/foto_place/<?php echo $row->foto_place?>"><img src="http://localhost/ta/img/thumb_place/<?php echo $row->foto_place?>" alt="" width="50" height="50" /></a></li>
				</div>
				<?php endforeach?>				
			</ul>
											
			<?php if($photos):?>			
			<ul class="gallery3">
				<?php foreach($photos as $row):?>
				<div class="fotoplace">
				<li><a title="" rel="prettyPhoto" href="http://localhost/ta/img/foto_place/<?php echo $row->foto_place?>"><img src="http://localhost/ta/img/thumb_place/<?php echo $row->foto_place?>" alt="" width="50" height="50" /></a></li>
				<?php foreach($data as $user):?>
				<?php if ($user->iduser == $this->session->userdata('id_user') || ($this->session->userdata('id_user') == 1 ) ):?>
				<div class="delfotoplace" idphoto="<?php echo $row->idplace_photo ?>" idplace="<?php echo $row->id_place?>" title="<?php echo $row->id_place?>">x</div>
				<?php endif?>
				<?php endforeach?>
				</div>
				
				<?php endforeach?>
			</ul>			
			<?php endif?>			
			</div>
			
			
			<div class="myphoto2">
				<div class="changephoto">Change</div><div class="addphoto">Add more</div><div class="canceladd">Cancel</div>
			</div>
			
			<div class="myphoto3">
			<div class="tipsbrowse">Browse some photo here.</div><div class="cancelchange" title="Cancel">x</div>
			<?php echo form_open_multipart('place/updatephoto');?>
			<div id="divinputfile2"> 
				<input name="userfile" type="file" size="6" id="userfile2" onchange="this.form.fakefilepc2.value = this.value;"/>
				<div id="fakeinputfile2">
					<input name="fakefilepc2" type="text" id="fakefilepc2" />
					<input type="hidden" name="id_place" id="id_place" value="<?php echo $data2->id_place?>"/>
					<input type="submit" id="updatephoto" class="updatephoto" value="Upload"/>					
				</div>				
			</div>
			</form>
			</div>
			
			<div class="myphoto4">
			<div class="tipsbrowse">Add more photo.</div><div class="cancelchange" title="Cancel">x</div>
			<?php echo form_open_multipart('place/addphoto');?>
			<div id="divinputfile2"> 
				<input name="userfile" type="file" size="6" id="userfile2" onchange="this.form.fakefilepc2.value = this.value;"/>
				<div id="fakeinputfile2">
					<input name="fakefilepc2" type="text" id="fakefilepc2" />
					<input type="hidden" name="id_place" id="id_place" value="<?php echo $data2->id_place?>"/>
					<?php if ($totalphotos):?>
					<?php foreach ($totalphotos as $row):?>
					<input type="hidden"  name="total" value="<?php echo $row->total?>"/>
					<?php endforeach?>
					<?php endif?>
					<input type="submit" id="updatephoto" class="updatephoto" value="Upload"/>					
				</div>				
			</div>
			</form>
			</div>
			
		</div>
		<div class="clear"></div>
		
		<div id="comentator">
			<div class="titlebox">Most Comments</div>
			<div class="clear"></div>
			<?php 
				if ($commentator){
				foreach($commentator as $row){
				if($row->id_user == $this->session->userdata('id_user')){
					echo '<div class="commentator">';
					if ($row->avatar == 0){
						echo '<div class="imgcommentator" title="'.$row->username.'">'.anchor('profile',img(array('src'=>'http://localhost/ta/img/default.jpg','width'=>25,'height'=>25))).'</div>';
					}else{
						echo '<div class="imgcommentator" title="'.$row->username.'">'.anchor('profile',img(array('src'=>'img/thumb_foto/'.$row->filename,'width'=>25,'height'=>25))).'</div>';
					}
					echo '<div class="imgcom">'.$row->total.'</div>';
					echo '</div>';
				}else{
					echo '<div class="commentator">';
					if ($row->avatar == 0){
						echo '<div class="imgcommentator" title="'.$row->username.'">'.anchor('people/view/'.$row->id_user,img(array('src'=>'http://localhost/ta/img/default.jpg','width'=>25,'height'=>25))).'</div>';
					}else{					
						echo '<div class="imgcommentator" title="'.$row->username.'">'.anchor('people/view/'.$row->id_user,img(array('src'=>'img/thumb_foto/'.$row->filename,'width'=>25,'height'=>25))).'</div>';
					}
					echo '<div class="imgcom">'.$row->total.'</div>';
					echo '</div>';
				}
				}
				}else{
					echo 'No comment yet';
				}
			?>
		</div>
		<div id="voter">
			<div class="titlebox">Who Likes</div>
			<div class="clear"></div>
			<?php 
			if ($voter){
				foreach($voter as $row){
				if($row->id_user == $this->session->userdata('id_user')){
					echo '<div class="voter">';
					if ($row->avatar == 0){
						echo '<div class="imgvoter" title="'.$row->username.'">'.anchor('profile',img(array('src'=>'http://localhost/ta/img/default.jpg','width'=>25,'height'=>25))).'</div>';
					}else{
						echo '<div class="imgvoter" title="'.$row->username.'">'.anchor('profile',img(array('src'=>'img/thumb_foto/'.$row->filename,'width'=>25,'height'=>25))).'</div>';
					}
					echo '</div>';
				}else{
					echo '<div class="voter">';
					if ($row->avatar == 0){
						echo '<div class="imgvoter" title="'.$row->username.'">'.anchor('people/view/'.$row->id_user,img(array('src'=>'http://localhost/ta/img/default.jpg','width'=>25,'height'=>25))).'</div>';
					}else{
						echo '<div class="imgvoter" title="'.$row->username.'">'.anchor('people/view/'.$row->id_user,img(array('src'=>'img/thumb_foto/'.$row->filename,'width'=>25,'height'=>25))).'</div>';
					}
					echo '</div>';
				}
				}
			}else{
				echo 'No vote yet';
			}
			?>
		</div>
		
		
	</div>
</div>
</div>
</body>
</html>